package com.tcs.kafka.producer.sender;

import org.springframework.kafka.support.SendResult;
import org.springframework.util.concurrent.FailureCallback;
import org.springframework.util.concurrent.SuccessCallback;

/**
 * 针对于 producer API
* @Title: IKafkaSender.java
* @Package com.tcs.kafka.producer.sender
* @author 神经刀
* @date 2018年10月15日
* @version V1.0
 */
public interface IKafkaSender<K,T> {
	
	/**
	* @Title: sendMessage  
	* @Description: Kafka发送
	* @param topic
	* @param partition
	* @param timestamp
	* @param key
	* @param data    参数  
	 */
	public void sendMessage(String topic, Integer partition, Long timestamp,  K key, T data);
	
	/**
	* @Title: sendMessage  
	* @Description: Kafka发送
	* @param topic
	* @param partition
	* @param timestamp
	* @param key
	* @param data    参数  
	* @param successCallback
	* @param failureCallback
	 */
	public void sendMessage(String topic, Integer partition, Long timestamp,  K key, T data ,SuccessCallback<SendResult<K, T>> successCallback , FailureCallback failureCallback);
	
	/**
	* @Title: sendMessage  带有负载均衡器
	* @Description: Kafka发送
	* @param topic
	* @param partition
	* @param timestamp
	* @param key
	* @param data    参数  
	* @param successCallback
	* @param failureCallback
	* @param balance 负载均衡方式    balance : 1. 轮训. 2. 随机 
	 */
	public void sendMessage(String topic, Integer partition, Long timestamp,  K key, T data ,SuccessCallback<SendResult<K, T>> successCallback , FailureCallback failureCallback , SenderBalance balance);
}
